<?php 
include_once('includes.php'); 	

?>
<?php include_once('includes/header.php'); 	 ?>
<script>

$(document).ready(function ()
{
 setTimeout("frequentlyUpdateRemainingTime();",1000);
 
});

</script>

 
<div style="float:right; padding-bottom:10px">
	<!-- AddThis Button BEGIN -->
	<div class="addthis_toolbox addthis_default_style ">
	<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
	<a class="addthis_button_tweet"></a>
	<a class="addthis_button_google_plusone" g:plusone:size="medium"></a>
	</div>
	<script type="text/javascript" src="/js/addthis_widget.js"></script>
	<!-- AddThis Button END -->
</div>

<?php

$sql = "select  matchs.*, competition.name as cname,competition.classicon as cicon  from matchs left join competition on matchs.competition_id = competition.id   where  is_feature=1 and status<2 order by status desc ,kick_off asc ";
$matchs=db_fetch_all($sql);
if(count($matchs)>0) 
{
	
?>
<div class="clearfix" style="margin-bottom:10px;">
	<ul class="feature-matchs">
	<?php 
	foreach($matchs as $match)
	{
		list($team1, $team2) = split('-',$match->versus);
	
		$local_kick_off = convertTimeToLocal($match->kick_off,$match->timezone);
		
		$team1_logo = getTeamLogo($match->team1_id);
		$team2_logo = getTeamLogo($match->team2_id);
		
		$team1_logo = (check_file($_SERVER["DOCUMENT_ROOT"].$team1_logo))?$team1_logo:"/images/football.png";
		$team2_logo = (check_file($_SERVER["DOCUMENT_ROOT"].$team2_logo))?$team2_logo:"/images/football.png";
		
		$team1_info = db_fetch_one("	SELECT *
						FROM team_info 
						WHERE name in ( 	SELECT namphan 
											FROM team_name_matching 
											WHERE luanvo = '".trim($team1)."'
										)
					");
					
		$team2_info = db_fetch_one("	SELECT *
						FROM team_info 
						WHERE name in ( 	SELECT namphan 
											FROM team_name_matching 
											WHERE luanvo = '".trim($team2)."'
										)
					");					
		
	?>
		<li> 
			<div class="col-team1" > 
				<span>
					<?php
						if($team1_info != null && false)
						{
							?>
							<a id="player_<?php echo str_replace(" ","_",trim($team1)); ?>" href="/team-info/<?php echo $match->team1_id . "-" . str_replace(" ","-",trim($team1)); ?>" onmouseover="show_tip(&quot;player_tip_<?php echo str_replace(" ","_",trim($team1)); ?>&quot;);" onmouseout="hide_tip(&quot;player_tip_<?php echo str_replace(" ","_",trim($team1)); ?>&quot;);">
								<?php echo $team1; ?>
							</a>
							<?php
						}
						else
						{
							echo $team1;
						}
					?>
				</span>
				<img class="teamicon" src="<?php echo $team1_logo;?>"/>
			</div>
			<div class="col-info">
				<div class="hover"> 
					<?php 
						echo remainTime($local_kick_off,'<div class="remainingTime countdown"><span class="NoDisplay">Trận đấu sẽ diễn ra sau <b class="remainingDay">%d </b> ngày <b class="remainingHour">%h </b> giờ <b class="remainingMinute">%m </b> phút <b class="remainingSecond">0</b> giây</span><span class="TimeDisplay"><span class="Text"></span><span class="Time"></span></span></div>'); 
					?>
				</div>
				<span style="font-size:15px"> <?php echo $match->cname; ?></span> 
				<span> <?php echo formatOutputDate($local_kick_off); ?>  </span>
				<span style="text-transform:uppercase"><a href="/match/<?php echo $match->id."-".clean_entities($match->versus); ?>" title="Watch this match"><strong>Xem trận này</strong></a>  </span>
			</div>
			<div class="col-team2" >
				<img class="teamicon" src="<?php echo $team2_logo;?>"/>
				<span>
					<?php
						//$temp=db_fetch_all("SELECT name FROM player WHERE team_name in (SELECT namphan FROM team_name_matching WHERE luanvo = '".trim($team2)."')");
						if($team2_info != null && false)
						{
							?>
							<a id="player_<?php echo str_replace(" ","_",trim($team2)); ?>" href="/team-info/<?php echo $match->team2_id . "-" . str_replace(" ","-",trim($team2)); ?>" onmouseover="show_tip(&quot;player_tip_<?php echo str_replace(" ","_",trim($team2)); ?>&quot;);" onmouseout="hide_tip(&quot;player_tip_<?php echo str_replace(" ","_",trim($team2)); ?>&quot;);">
								<?php echo $team2; ?> 
							</a>
							<?php
						}
						else
						{
							echo $team2;
						}
					?>
				</span>
			</div>
			
		</li>
		<?php

		if($team1_info != null)
		{
		?>
		<div class="xtip" id="player_tip_<?php echo str_replace(" ","_",trim($team1)); ?>" style="visibility: hidden;">
			<div class="ballon">
				<div class="tla" id="tla_player_tip_<?php echo str_replace(" ","_",trim($team1)); ?>" style="display: inline;">
				</div>
				<div class="tra" id="tra_player_tip_<?php echo str_replace(" ","_",trim($team1)); ?>" style="display: none;">
				</div>
				<div id="balloonBody">
					<h4>
					</h4>
					<div class="boxBody">
						<?php echo $team1_info->html; ?>
					</div>
					<div class="boxFooter">
						<p>
						</p>
					</div>
				</div>
				<div class="bla" id="bla_player_tip_<?php echo str_replace(" ","_",trim($team1)); ?>" style="display: none;">
				</div>
				<div class="bra" id="bra_player_tip_<?php echo str_replace(" ","_",trim($team1)); ?>" style="display: none;">
				</div>
			</div>
		</div>
		<?php
		}
		if($team2_info != null)
		{
		?>
		<div class="xtip" id="player_tip_<?php echo str_replace(" ","_",trim($team2)); ?>" style="visibility: hidden;">
			<div class="ballon">
				<div class="tla" id="tla_player_tip_<?php echo str_replace(" ","_",trim($team2)); ?>" style="display: inline;">
				</div>
				<div class="tra" id="tra_player_tip_<?php echo str_replace(" ","_",trim($team2)); ?>" style="display: none;">
				</div>
				<div id="balloonBody">
					<h4>
					</h4>
					<div class="boxBody">
						<?php echo $team2_info->html; ?>
					</div>
					<div class="boxFooter">
						<p>
						</p>
					</div>
				</div>
				<div class="bla" id="bla_player_tip_<?php echo str_replace(" ","_",trim($team2)); ?>" style="display: none;">
				</div>
				<div class="bra" id="bra_player_tip_<?php echo str_replace(" ","_",trim($team2)); ?>" style="display: none;">
				</div>
			</div>
		</div>
	<?php
		}
	}
	?>
	</ul>
	<span class="morelink"> <em><a href="/live-streaming" title="Xem tất cả lịch trực tiếp các trận sắp diễn ra">Xem tất cả...</a> </em> </span>
</div>

<?php
}
?>


<?php
//start box matchs Now playing
$sql = "select matchs.*, competition.name as cname,competition.classicon as cicon  from matchs left join competition on matchs.competition_id = competition.id  where  status=1  order by kick_off asc limit 5 ";
$matchs=db_fetch_all($sql);
if(count($matchs)>0) 
{
?>	
<div class="cbox playing clearfix">
	<span class="title">Các trận đang diễn ra</span>
	<div class="content">
		<ul class="matchs">
	<?php 
	
	foreach($matchs as $match)
	{
		$local_kick_off = convertTimeToLocal($match->kick_off,$match->timezone);
	?>
		<li class="<?php echo $match->cicon; ?>"> 
			<div class="cname"><?php echo $match->cname; ?></div>
			<div class="kick-off"><?php echo formatOutputDate($local_kick_off); ?></div>
			<div class="vs">	<a href="/match/<?php echo $match->id."-".clean_entities($match->versus); ?>"><strong><?php echo $match->versus; ?></strong></a>  </div>
			
		</li>
	<?php
	}
	?>	
		<span class="morelink"> <em><a href="/live-streaming" title="Xem tất cả các trận đang diễn ra">Xem tất cả...</a> </em> </span>
		</ul>
	</div>
</div>	
<?php
}
?>


<?php
$sql = "select  highlights.id as hid, highlights.* ,matchs.*, competition.name as cname, competition.id as cid, competition.classicon as cicon from   highlights left join matchs on highlights.match_id = matchs.id left join competition on matchs.competition_id = competition.id where  status=2  order by matchs.kick_off desc limit 10 ";
$matchs=db_fetch_all($sql);

if(count($matchs)>0) 
{
?>

<div class="cbox clearfix">
	<span class="title">Video bàn thắng</span>
	<div class="content">
		<ul class="matchs">
	<?php 
	foreach($matchs as $match)
	{
		$local_kick_off = convertTimeToLocal($match->kick_off,$match->timezone);
	
		list($team1, $team2 ) = split('-',$match->versus);
		$team1 = trim($team1);
		$team2 = trim($team2);
	?>
		<li class="<?php echo $match->cicon; ?>"> 
			<div class="cname"><?php echo $match->cname; ?></div>
			<div class="kick-off"><?php echo formatOutputDate($local_kick_off); ?></div>
			<div class="vs">	<a href="/match/<?php echo $match->id."-".clean_entities($match->versus); ?>"><strong><?php echo $team1." ".$match->score." ".$team2;?></strong></a>  </div>
			
		</li>
	<?php
	}
	?>
		</ul>
		<span class="morelink"> <em><a href="/highlights" title="Xem tất cả Video bàn thắng và diễn biến chính của trận đấu">Xem tất cả...</a> </em> </span>
	</div>
</div>
<?php
}
?>



<!-- Start VIDEO -->
<div>

	<script src="/includes/scrollable/jquery.tools.min.js"></script> 
	<link rel="stylesheet" type="text/css" href="/includes/scrollable/scrollable-horizontal.css" /> 
	<link rel="stylesheet" type="text/css" href="/includes/scrollable/scrollable-buttons.css" /> 
	<link rel="stylesheet" type="text/css" href="/includes/scrollable/scrollable-navigator.css" /> 
	 
	<!-- wrapper for navigator elements --> 
	<div class="navi"></div> 
	 
	<!-- "previous page" action --> 
	<a class="prev browse left"></a> 
	<!-- root element for scrollable --> 
	<div class="scrollable" id=browsable>   
	   
	   <!-- root element for the items --> 
	   <div class="items"> 
			
				
			<?php
				$sql = "select  * from video order by date_created desc limit 50 ";
				$videos=db_fetch_all($sql);
				
				$i=0;	
				foreach($videos as $video)
				{
					$i++;
					if($i%5==1)
						echo "<div>";
						
					echo "<div class='item'> <a href='/video/".$video->id."-".clean_entities($video->title)."'><img src='".$video->thumb_image."' /> </a> <span class='title'>".$video->title."</span> </div>";
					if($i%5==0 || $i==count($videos))
						echo "</div>";
				}
			?>
		
		</div> 
	</div> 
	 
	<!-- "next page" action --> 
	<a class="next browse right"></a> 
	 
	 
	<br clear="all" /> 
	 
	<!-- javascript coding --> 
	<script> 
	// What is $(document).ready ? See: http://flowplayer.org/tools/documentation/basics.html#document_ready
	$(document).ready(function() {
		$("#browsable").scrollable({circular: true, mousewheel: true}).navigator().autoscroll({
			interval: 8000		
		});

	});
	</script> 
	 

</div>

<!-- End VIDEO -->
<?php include_once('includes/footer.php'); 	 ?>